package com.job.learn.cuiyt.service;

import com.alibaba.fastjson.JSON;
import com.job.learn.cuiyt.dto.Person;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * @author: cuiyutian1
 * @date: 2021/12/26 18:44
 * @description:
 */
@Slf4j
@Component
public class PersonService {

    public void dealPerson(int sex){
        List<Person> list = getList();

        for (Person person : list) {
            if(person.getSex() == sex){
                log.info("deal person info: {}", JSON.toJSONString(person));
            }
        }
    }


    public List<Person> getList(){
        ArrayList<Person> list = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            Person person = new Person();
            person.setName(UUID.randomUUID().toString().substring(0,4));
            if( i % 2 == 0){
                person.setSex(0);
            }else{
                person.setSex(1);
            }
            list.add(person);
        }
        return list;
    }
}
